package com.richard.cloud.service;

import java.math.BigDecimal;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.richard.cloud.entity.Account;
import com.richard.cloud.repo.AccountRepo;

@Service
public class AccountService {
	@Resource
	private AccountRepo repo;
	
	//扣款
	//@Transactional
	public void charge(Long custId, BigDecimal amount) {
		Account entity = repo.findByCustId(custId);
		entity.setBalance(entity.getBalance().subtract(amount));
		repo.saveAndFlush(entity);
	}
}
